package com.code8086.working;

import java.io.InputStream;
import java.util.Properties;

public class Employee
{
	public String Name;
	public String Type;
	public WorkingDay[] work;
	public double total_working_time;
	public double standard_working_time;
	public double extra_working_time;
	
	public Employee()
	{
		work = new WorkingDay[31];
		total_working_time = 0.00;
		for (int i = 0; i < 31; i++)
		{
			work[i] = new WorkingDay();
		}
	}
	
	public void calTotalWorkingTime ()
	{
		total_working_time = 0.00;
		for (int i = 0; i < 31; i++)
		{
			total_working_time += work[i].calWorkingTime();
		}
	}
	
	public void calStandartWorkingTime () throws Exception
	{
		Properties properties = new Properties();
		InputStream in = getClass().getResourceAsStream("config.properties");
		properties.load(in);
		String str = properties.getProperty(Type + "标准时间");
		standard_working_time = Double.valueOf(str);
	}
	
	public void calExtraWorkingTime ()
	{
		extra_working_time = total_working_time - standard_working_time;
	}
	
	
	public void outputInfoFormat ()
	{
		System.out.printf("姓名:%s    编号:%s    类型: %s\n", Name.split("_")[0], Name.split("_")[1], Type);
		System.out.printf("总工作时间:%.2f\n" , total_working_time);
		System.out.printf("标准时间:%.2f    加班时间:%.2f\n", standard_working_time, extra_working_time);
		System.out.println("==========================================");
	}
	
	public void outputInfo ()
	{
		System.out.println("姓名:" + Name.split("_")[0] + "    编号:" + Name.split("_")[1] + "    类型:" + Type);
		System.out.println("总工作时间:" + total_working_time);
		System.out.println("标准时间:" + standard_working_time + "    加班时间:" + extra_working_time);
		System.out.println("==========================================");
	}
}
